package com.clearance.mine_clearance.controller;

import com.clearance.mine_clearance.entry.Result;
import com.clearance.mine_clearance.entry.UserLogin;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@CrossOrigin("*")
@RestController
@RequestMapping("/mine/user")
public class AdminUserLogin {

    @PostMapping("/login")
    public Result login(@RequestBody UserLogin user){
        if(user.getUserName()==null||user.getPassWorld()==null){
            return new Result().error("缺少账号和密码");
        }
        if(user.getUserName().equals("admin")&&user.getPassWorld().equals("123456")){
            Map<String,String> result = new HashMap<>();
            result.put("userName",user.getUserName());
            result.put("passWorld",user.getPassWorld());
            return new Result().success(result);
        }else {
            return new Result().error("账号或密码错误");
        }
    }
}
